{extend name="extra@index/base" /}
{block name="title"}用户登录{/block}

{block name="css"}

{/block}


{block name='page'}
<style>/**页面css写在这里*/
.icon-xitongfanhui:before {
    padding-right: 0.75rem;
}

.card-header {
    background: #0099FF;
    color: white;
}

.iconfont {
    font-size: 0.85rem;
}
</style>
<!-- 页面开始 -->
<div id="vue">
    <div class="card-header">
        <span class="login"><span class="iconfont icon-xitongfanhui" onclick="back()">登录</span></span>
        <a href="/my/index/register/" style="color: white">会员注册</a>
    </div>
    <div class="list-block">
        <ul>
            <li>
                <div class="item-content">
                    <div class="item-media"></div>
                    <div class="item-inner">
                        <div class="item-title label">用户名</div>
                        <div class="item-input">
                            <input type="text" placeholder="邮箱地址/用户名" v-model="account">
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <div class="item-content">
                    <div class="item-media"></div>
                    <div class="item-inner">
                        <div class="item-title label">密码</div>
                        <div class="item-input">
                            <input type="password" placeholder="密码" v-model="password">
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>


    <div class="content-block">
        <p><a @click="login" class="button button-fill button-success  button-big">立即登录 </a></p>
    </div>


</div>


<script>

    var vm = new Vue({
        el: '#vue',
        data: function () {
            return {
                account: '',
                password: ''
            }
        },
        ready: function () {

        },
        methods: {
            login: function () {

                if (!vm.account) return $.alert("请输入账号");
                if (!vm.password) return $.alert("请输入密码");
                $.showPreloader('正在登录')
                $.post('/api/my/login', vm.$data, function (ret) {

                    $.hidePreloader();

                    $.alert(ret.msg, function () {
                        if (ret.code > 0) {

                            initRongCloud()

                            back()

                        }
                    })

                })


            }
        }
    })


    if (!(document.cookie || navigator.cookieEnabled)) {
        $.alert('cookie 未打开!将不能正常登录注册');
    }


    function back() {
        var from = '{:input("from")}';
        if (from) {
            $.router.load(from, true, 'left');
        } else {
            $.router.load('/my/', true, 'left');
        }


    }


</script>


<!-- 页面结束 -->
{/block}


{block name="base"}
<div class="panel-overlay"></div>
<div class="panel panel-left panel-reveal theme-dark" id='panel-left'>
    <!-- 左边侧栏开始 -->

    <!-- 左边侧栏结束 -->
</div>
{/block}

{block name="js"}

{/block}